package com.edais.service.imp;

import com.edais.dao.UserExtractInfoDao;
import com.edais.domain.ExtractConfig;
import com.edais.domain.UserExtractInfo;
import com.edais.domain.gift.PointGrade;
import com.edais.service.UserExtractInfoService;
import com.edais.util.CommonUtil;
import com.edais.util.Consts;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Service
public class UserExtractInfoServiceInfo implements UserExtractInfoService {
	private static final Log logger = LogFactory.getLog(UserExtractInfoServiceInfo.class);
	
	@Autowired 
	private UserExtractInfoDao userextractInfoDao;

	/**
	 * 根据用户ID查询用户积分等级信息
	 */
	@Override
	public PointGrade queryPointGradeByUserId(String userId) {
		Map<String,Object> paramsMap = new HashMap<String,Object>();
		paramsMap.put("userId", userId);
		return userextractInfoDao.queryPointGradeByUserId(paramsMap);
	}

	/**
	 * 根据用户积分等级信息查询等级配置
	 */
	@Override
	public ExtractConfig queryExtractConfigByPointGrade(String grade) {
		Map<String,Object> paramsMap = new HashMap<String,Object>();
		paramsMap.put("pointGrade", grade);		
		return userextractInfoDao.queryExtractConfigByPointGrade(paramsMap);
	}

	/**
	 * 根据参数查询用户提现信息
	 */
	@Override
	public UserExtractInfo getUserExtractInfo(Map<String, Object> paramsMap) {
		return this.userextractInfoDao.getUserExtractInfo(paramsMap);
	}

	@Override
	public Map<String, Object> queryExtractCashFront(String logInfo, Map<String, Object> params)throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();

		Map coreMap = CommonUtil.invokeCore(logInfo, "queryExtractCashFront", params);
		if (coreMap == null || !"00000".equals(coreMap.get("rescode"))) {
			logger.error(logInfo + "查询提现申请信息失败：" + coreMap.get("resmsg"));
			map.put("rescode", Consts.ERROR_CODE);
			map.put("resmsg", Consts.ErrorMsg.MSG00001);
			map.put("resmsg_cn", "查询提现申请信息失败");
			return map;
		}
		return coreMap;
	}
	

}
